#!/bin/bash

# 直接测试MCP工具功能的脚本

PROJECT_ROOT="$(dirname "$(dirname "$(realpath "$0")")")"
BINARY="$PROJECT_ROOT/bin/k8s-mcp-server"

echo "K8s MCP 工具直接测试"
echo "项目路径: $PROJECT_ROOT"
echo
export KUBECONFIG="$PROJECT_ROOT/config/kube-config"

# 颜色定义
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m'

echo -e "${BLUE}测试 1: 工具列表${NC}"
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | "$BINARY" | head -20
echo
echo "==============================="

echo -e "${BLUE}测试 2: 获取集群信息${NC}"
echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "k8s_get_cluster_info", "arguments": {}}}' | "$BINARY" | head -20
echo
echo "==============================="

echo -e "${BLUE}测试 3: 获取节点信息${NC}"
echo '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "k8s_get_nodes", "arguments": {"output_format": "wide"}}}' | "$BINARY" | head -20
echo
echo "==============================="

echo -e "${BLUE}测试 4: 获取命名空间${NC}"
echo '{"jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": {"name": "k8s_get_namespaces", "arguments": {}}}' | "$BINARY" | head -20
echo
echo "==============================="

echo -e "${BLUE}测试 5: 获取默认命名空间的Pods${NC}"
echo '{"jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": {"name": "k8s_get_pods", "arguments": {"namespace": "default"}}}' | "$BINARY" | head -20
echo
echo "==============================="

echo -e "${GREEN}所有MCP工具测试完成！${NC}" 